﻿using Microsoft.Extensions.Caching.Memory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WLYT.Common
{
    public class MemoryCacheHelper
    {
        private static readonly IMemoryCache MemoryCache;
        static MemoryCacheHelper()
        {
            if (MemoryCache == null)
            {
                MemoryCache = new MemoryCache(new MemoryCacheOptions());
            }
        }

        public static void SetCache(string key, object value)
        {
            MemoryCache.Set(key, value);
        }

        public static T GetCache<T>(string key)
        {
            return MemoryCache.Get<T>(key);
        }
    }
}
